'use strict'
const path = require('path')

let serverObj = {
  dev: {
    // Paths
    env: require('./dev.env'),
    assetsSubDirectory: 'static',
    assetsPublicPath: '/',
    host: 'localhost',
    // 如果你要上线到linux上面就用下面的，如果是自己开发就用上面的这个
    // host: 'web.lihexinzhiye.com',
    // host: 'zyjkweb.lihexinzhiye.com',
    port: 8080,
    autoOpenBrowser: true,
    errorOverlay: true,
    notifyOnErrors: true,
    poll: false,
    hotOnly: false, //热更新（webpack已实现了，这里false即可）
    proxyTable: {
      //配置跨域
      '/': {
        target: "http://gjjava.lihexinzhiye.com",//居家护理管理系统后端
        // 如果你要上线到linux上面就用上面的，如果是自己开发就用下面的这个
        // target: "http://localhost:8078",//本接口
        ws: true,
        changOrigin: true,
        pathRewrite: {}
      }
    },
    useEslint: false,
    showEslintErrorsInOverlay: false,
    devtool: 'cheap-module-eval-source-map',
    cacheBusting: true,
    cssSourceMap: true
  },

  build: {
    index: path.resolve(__dirname, '../dist/index.html'),

    // Paths
    assetsRoot: path.resolve(__dirname, '../dist'),
    assetsSubDirectory: 'static',
    assetsPublicPath: './',

    /**
     * Source Maps
     */

    productionSourceMap: true,
    devtool: '#source-map',
    productionGzip: false,
    productionGzipExtensions: ['js', 'css'],
    bundleAnalyzerReport: process.env.npm_config_report
  }
}

/**
 * 依据命令执行不同的代理文件
 * 全局变量在package.json里配置
 */

if (process.env.NODE_ENV === 'development') {
  if (process.env.DEV_ENV === 'local') {
    serverObj.dev.env = require('./dev.env')
    serverObj.dev.proxyTable = require('./dev.proxy')
  } else if (process.env.DEV_ENV === 'test') {
    serverObj.dev.env = require('./dev.test.env')
    serverObj.dev.proxyTable = require('./dev.test.proxy')
  } else {
    serverObj.dev.env = require('./dev.mock.env')
    serverObj.dev.proxyTable = require('./dev.proxy')
  }
}

if (process.env.NODE_ENV === 'production') {
  serverObj.build.env = (process.env.DEV_ENV === 'test' ? require('./prod.test.env') : require('./prod.env'))
}
module.exports = serverObj
